// components/count-down/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    time:{
      type:Number,
      value:60
    },
    useSlot:Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {

  },
  lifetimes:{
    attached(){
      this.countDownStart()
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    countDownStart(){
      let timer = null
      if(this.data.time === 0) return clearTimeout(timer)
      this.setData({
        time:this.data.time - 1
      })
      timer = setTimeout(this.countDownStart.bind(this),1000)
      this.triggerEvent('change',this.data.time)
    }
  }
})
